package cn.itlaobing.springmvc.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;

import cn.itlaobing.springmvc.dao.StudentMapper;
import cn.itlaobing.springmvc.entity.Student;
import cn.itlaobing.springmvc.service.StudentService;

@Service
public class StudentServiceImpl implements StudentService {

	
	@Autowired
	private StudentMapper studentMapper;
	
	

	@Override
	public List<Student> findBySearchFilter(Map<String,String> searchFilter) {
		
		if(searchFilter==null){
			searchFilter=new HashMap<>();
		}else{
			if(StringUtils.isBlank(searchFilter.get("pageNum"))){
				searchFilter.put("pageNum","1");
				
			}
			if(StringUtils.isBlank(searchFilter.get("pageSize"))){
				searchFilter.put("pageSize","3");
			}
		}		
		PageHelper.startPage(searchFilter); //map中需要包含 pageNum 和pageSize 
		return studentMapper.findBySearchFilter(searchFilter);
	}



	@Override
	public void save(Student student) {
	
	}


	@Override
	public Student findById(Long id) {
		
		return null;
	}


	@Override
	public void update(Student student) {
			
	}


	@Override
	public void delete(Long id) {
		
		
	}

}
